<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('项目详情')" />
	<th:block th:include="include :: select2-css" />
</head>

<body>
    <div class="main-content">
        <form class="form-horizontal"  id="form-user-edit" th:object="${product}">

           <!-- [[${item}]]-->

                <input name="productGuid" type="hidden" th:field="*{productGuid}"/>

<!--                <h4 class="form-header h4">基本信息</h4>-->
                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label ">物资编码：</label>
                            <div class="col-sm-8">
                                <input name="productId" th:field="*{productId}" placeholder="请输入物资编码" class="form-control" type="text" maxlength="30" READONLY
                                       >
                            </div>
                        </div>
                    </div>


                </div>

<!--                <div class="row">-->


<!--                    <div class="col-sm-6">-->
<!--                        <div class="form-group">-->
<!--                            <label class="col-sm-4 control-label ">ABC分类：</label>-->
<!--                            <div class="col-sm-8">-->
<!--                                <input id="productFlag" name="productFlag" th:field="*{productFlag}" placeholder="请输入ABC分类" class="form-control"-->
<!--                                       type="text" maxlength="30" >-->
<!--                            </div>-->
<!--                        </div>-->
<!--                    </div>-->

<!--                    <div class="col-sm-6">-->
<!--                        <div class="form-group">-->
<!--                            <label class="col-sm-4 control-label ">包装定额：</label>-->
<!--                            <div class="col-sm-8">-->
<!--                                <input id="specialFlag" name="specialFlag" th:field="*{specialFlag}" placeholder="请输入包装定额" class="form-control"-->
<!--                                       type="text" maxlength="30" >-->
<!--                            </div>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
                <div class="row">


                    <div class="col-sm-6">
                        <div class="form-group">
                            <label class="col-sm-4 control-label ">物资名称：</label>
                                <div class="col-sm-8">
                                    <input id="productName" name="productName"th:field="*{productName}"  placeholder="请输入物资名称"  class="form-control" type="text"
                                           maxlength="30" >
                                </div>
                        </div>
                    </div>
                </div>
<!--            <div class="row">-->
<!--                <div class="col-sm-6">-->
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-4 control-label ">体积：</label>-->
<!--                        <div class="col-sm-8">-->
<!--                            <input id="model" name="model"th:field="*{model}"  placeholder="请输入体积"  class="form-control" type="text"-->
<!--                                   maxlength="30" >-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
<!--                <div class="col-sm-6">-->
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-4 control-label ">单位：</label>-->
<!--                        <div class="col-sm-8">-->
<!--                            <input id="unit" name="unit"th:field="*{unit}"  placeholder="请输入单位" class="form-control" type="text"-->
<!--                                   maxlength="30" >-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="row">-->
<!--                <div class="col-sm-6">-->
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-4 control-label ">重量：</label>-->
<!--                        <div class="col-sm-8">-->
<!--                            <input id="spec" name="spec"th:field="*{spec}"  placeholder="请输入重量"  class="form-control" type="text"-->
<!--                                   maxlength="30" >-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->

<!--            </div>-->
<!--            <div class="row">-->
<!--                <div class="col-sm-6">-->
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-4 control-label ">货物条码：</label>-->
<!--                        <div class="col-sm-8">-->
<!--                            <input id="mnemonicCode" name="mnemonicCode"th:field="*{mnemonicCode}"  placeholder="请输入货物条码"  class="form-control" type="text"-->
<!--                                   maxlength="30" >-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
<!--                <div class="col-sm-6">-->
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-4 control-label is-required">大类：</label>-->
<!--                            <div class="col-sm-8">-->
<!--                                <input id="productLength" name="productLength"th:field="*{productLength}"  placeholder="请输入大类"  class="form-control" type="text"-->
<!--                                       maxlength="30" required>-->
<!--                            </div>-->
<!--                        </div>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="row">-->
<!--                <div class="col-sm-6">-->
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-4 control-label is-required">中类：</label>-->
<!--                        <div class="col-sm-8">-->
<!--                            <input id="productWidth" name="productWidth"th:field="*{productWidth}"  placeholder="请输入中类"  class="form-control" type="text"-->
<!--                                   maxlength="30" required>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
<!--                <div class="col-sm-6">-->
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-4 control-label is-required">小类：</label>-->
<!--                            <div class="col-sm-8">-->
<!--                                <input id="productHeight" name="productHeight"th:field="*{productHeight}"  placeholder="请输入小类"  class="form-control" type="text"-->
<!--                                       maxlength="30" required>-->
<!--                            </div>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="row">-->
<!--                <div class="col-sm-6">-->
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-4 control-label ">最小库存：</label>-->
<!--                        <div class="col-sm-8">-->
<!--                            <input id="lkMinkc" name="yxq"th:field="*{lkMinkc}"  placeholder="请输入最小库存"  class="form-control" type="text"-->
<!--                                   maxlength="30" >-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="row">-->
<!--                <div class="col-sm-6">-->
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-4 control-label ">最大库存：</label>-->
<!--                        <div class="col-sm-8">-->
<!--                            <input id="lkMaxkc" name="yxq"th:field="*{lkMaxkc}"  placeholder="请输入最大库存"  class="form-control" type="text"-->
<!--                                   maxlength="30" >-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="row">-->
<!--                <div class="col-sm-6">-->
<!--                    <div class="form-group">-->
<!--                        <label class="col-sm-4 control-label ">有效期：</label>-->
<!--                        <div class="col-sm-8">-->
<!--                            <input id="yxq" name="yxq"th:field="*{yxq}"  placeholder="请输入有效期"  class="form-control" type="text"-->
<!--                                   maxlength="30" >-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label ">入库优先级：</label>
                            <div class="col-sm-8">
                                <input id="oneStackingId" name="oneStackingId"th:field="*{oneStackingId}"  placeholder="入库优先级"  class="form-control" type="text"
                                       maxlength="30" >
                            </div>
                    </div>
                </div>
<!--            </div>-->
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">是否可用：</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <select id="useable" name="useable" class="form-control" type="text" th:field="*{useable}">
                                    <option value="Y">允许</option>
                                    <option value="N">不允许</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
                <!--<h4 class="form-header h4">其他信息</h4>-->
                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-xs-2 control-label">备注：</label>
                            <div class="col-xs-10">
                                <textarea name="remark" maxlength="500" th:field="*{remark}" class="form-control" rows="3"></textarea>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
    </div>

	<th:block th:include="include :: footer" />
	<th:block th:include="include :: select2-js" />
	<script type="text/javascript">
        var prefix = ctx + "bas/product";


        function submitHandler() {
            var data = $("#form-user-edit").serializeArray();
            console.log(data)
            //TODO 如果沒有选择项目组（项目组为空 不允许提交）
            $.operate.save(prefix + "/edit", data);
	    }

        /* 用户管理-修改-选择部门树 */
        function selectDeptTree() {
        	var deptId = $.common.isEmpty($("#treeId").val()) ? "100" : $("#treeId").val();
            var url = ctx + "system/dept/selectDeptTree/" + deptId;
		    var options = {
				title: '选择部门',
				width: "380",
				url: url,
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}

		function doSubmit(index, layero){
			var tree = layero.find("iframe")[0].contentWindow.$._tree;
   			var body = layer.getChildFrame('body', index);
   			$("#treeId").val(body.find('#treeId').val());
   			$("#treeName").val(body.find('#treeName').val());
            selectgroups();
   			layer.close(index);
		}

		$(function() {
            $('#post').select2({
                placeholder: "请选择岗位",
                allowClear: true
            });
        })
        //分配项目组
        function selectgroups() {
            var deptId = $("#treeId").val();
            var url = ctx + "system/item/selectPrjgroupByDeptId/" + deptId;
            $.get(url, function (result) {
                console.log(result)
                var html = ""
                if(result.length>0){
                    for (var i = 0; i < result.length; i++) {
                        html += "<option  value=" + result[i].prjgroupId + ">" + result[i].prjgroupName + "</option>"
                    }
                }

                $("#prjGroup").html(html)
            })

        }
    </script>
</body>
</html>